import request from "@/utils/request";

//上传图片时，获取oss数据
export const aliOssSecurityToken = () => {
  return request({
    url: "sass/file/getAliOssSecurityToken",
    method: "get"
  });
};

//查询商品规格list
export const getSpecificationList = props => {
  return request({
    url: "/mall/admin/specification/getSpecificationList",
    method: "post",
    data: props
  });
};

//添加、编辑商品规格
export const saveSpecification = props => {
  return request({
    url: "/mall/admin/specification/saveSpecification",
    method: "post",
    data: props
  });
};

//删除商品规格
export const deleteSpecification = props => {
  return request({
    url: "/mall/admin/specification/deleteSpecification",
    method: "delete",
    params: props
  });
};

//复制商品规格
export const copySpecification = props => {
  return request({
    url: "/mall/admin/specification/copySpecification",
    method: "post",
    data: props
  });
};

// ===================新增/编辑===========================

//图片上传，存到业务端
export const imgsUpload = props => {
  return request({
    url: "/sass/file/upload",
    method: "post",
    data: props
  });
};

// 获取商品分类tree
export const getcategoryList = props => {
  return request({
    url: "/mall/admin/category/getcategoryList?search=" + props.searchkey,
    method: "get"
  });
};
//查询商品属性+通用属性list列表tree
export const getStastsListAll = props => {
  return request({
    url: "/mall/tenant/stasts/getStastsCommonList", //过滤掉禁用的规格
    method: "post",
    data: props
  });
};

//获取上架协议内容
export const getAgreementList = props => {
  return request({
    url: "/mall/agreement/getAgreementList",
    method: "get",
    params: props
  });
};

//获取数据字典
export const getEnumAll = props => {
  return request({
    url: "/dbo/system/dict/type/getAll",
    method: "get",
    params: props
  });
};

//获取商品规格
export const getSpecList = props => {
  return request({
    url: "/mall/admin/specification/getSpecificationList", //过滤掉禁用的规格
    method: "post",
    data: props
  });
};

//查询商品属性list列表tree
export const getStastsList = props => {
  return request({
    url: "/mall/admin/stasts/getStastsListByTree",
    method: "post",
    data: props
  });
};
// 省市区
export function getArea() {
  return request({
    url: "/dbo/region/tree"
  });
}

//创建-保存、发布商品
export const saveProduct = props => {
  return request({
    url: "/mall/tenant/factory/product/create",
    method: "post",
    data: props
  });
};
//获取商品详情
export const getProductDetail = props => {
  return request({
    url: "/mall/tenant/factory/product/getDetail",
    method: "post",
    data: props
  });
};
//编辑商品
export const eidtProduct = props => {
  return request({
    url: "/mall/tenant/factory/product/save",
    method: "post",
    data: props
  });
};

//查询商品富文本详情内容
export const getRichText = props => {
  return request({
    url: "/sass/rich/getRichText",
    method: "post",
    data: props
  });
};
//保存商品富文本详情内容
export const saveRichText = props => {
  return request({
    url: "/sass/rich/saveSassRichText",
    method: "post",
    data: props
  });
};
// 获取商品品牌列表
export const getBrandListApi = props => {
  return request({
    url: "/mall/common/getBrandList",
    method: "get",
    params: props
  });
};

/**
 * 2.获取分类列表
 */
export const categoryList = data => {
  return request({
    url: `/mall/tenant/factory/product/getFacotryCategoryList/${data.factoryId}`,
    method: "get"
  });
};

/**
 * 分页商品查询
 */
export const getSpListPage = data => {
  return request({
    url: "/mall/admin/product/customer/pageList",
    method: "post",
    data
  });
};

/**
 * 获取品牌列表
 */
export const getBrandInfoList = data => {
  return request({
    url: `/mall/tenant/brand/getBrandInfoList/${data.factoryId}`,
    method: "get"
  });
};
/**
 * 2.定制模板列表(下拉)
 */
export const getCustomList = data => {
  return request({
    url: "/mall/tenant/customization/template/list",
    method: "post",
    data
  });
};
